package main

import (
	"fmt"
	"time"
)

func main() {
	// 时间和日期函数
	now := time.Now() //2025-03-10 22:02:43.949235 +0800 CST m=+0.000778376
	fmt.Printf("%v ~~~对应类型为：%T", now, now)
	fmt.Println()
	fmt.Printf("时间格式化：年：%v \n", now.Year())
	fmt.Printf("时间格式化：月：%v \n", now.Month())
	fmt.Printf("时间格式化：日：%v \n", now.Day())
	fmt.Printf("时间格式化：时：%v \n", now.Hour())
	fmt.Printf("时间格式化：分：%v \n", now.Minute())
	fmt.Printf("时间格式化：秒：%v \n", now.Second())
	fmt.Printf("时间格式化：%d-%d-%d %d:%d:%d \n", now.Year(), now.Month(),
		now.Day(), now.Hour(), now.Minute(), now.Second())

	dateStr := fmt.Sprintf("当前时间为：%d-%d-%d %d:%d:%d \n", now.Year(), now.Month(),
		now.Day(), now.Hour(), now.Minute(), now.Second())
	fmt.Println(dateStr)

	//"2006/01/02 15/04/05" 固定数字
	dateStr2 := now.Format("2006/01/02 15/04/05")
	fmt.Println(dateStr2)
}
